package cn.proxy.dymanic;

import java.lang.reflect.Proxy;

import cn.proxy.statc.UserService;
import cn.proxy.statc.UserServiceImpl;

public class DynamicProxyTest {
	public static void main(String[] args) {
		UserService userService = new UserServiceImpl();
		UserService userService1 = (UserService)Proxy.newProxyInstance(UserService.class.getClassLoader(), new Class[] {UserService.class}, new DynamicProxyHandler(userService));
		
		userService1.sayHello();
		userService1.getHelo();
		
		System.out.println(userService);
		System.out.println(userService1);
		
		System.out.println("-----------------------");
		
		UserService service = new UserServiceImpl();
		DynamicProxyHandler handler = new DynamicProxyHandler(service);
		
		Object proxy = handler.getProxy();
		System.out.println(proxy);
		
		
		
		
		
	}
}
